<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>

    async function fn(){
        return 123;
    }

    console.log(fn())

    fn().then(function (data){
        console.log(data)
    })



    //通过回调函数可以拿到定时异步的结果

    function f2(callback){
        setTimeout(function (){

            callback("回调函数")
        },2000)
    }


    f2(function (data){
        console.log(data)
    })





    console.log(111);

    setTimeout(function (){
        console.log(222)
    },2000);

    setTimeout(function (){
        console.log(333)
    },0);

    console.log(4444)


    //  1  4   3   2   先执行同步代码   再执行异步代码
</script>
</body>
</html>